package logic

import (
	"context"
	"house/models"

	"house/house"
	"house/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseUpdateLogic {
	return &HouseUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 房源上架
func (l *HouseUpdateLogic) HouseUpdate(in *house.HouseUpdateReq) (*house.HouseUpdateResp, error) {
	// todo: 房源上架
	var err error
	var h models.House
	err = h.Update(int(in.HouseId), int(in.Status))
	if err != nil {
		logx.Error("修改失败")
		return nil, err
	}
	return &house.HouseUpdateResp{
		Id: int64(h.ID),
	}, nil
}
